fix: handle non-UTF-8 filenames in git ls-files on Windows#1893
Open
he-yufeng wants to merge 1 commit intoMoonshotAI:mainfrom
Open
fix: handle non-UTF-8 filenames in git ls-files on Windows#1893he-yufeng wants to merge 1 commit intoMoonshotAI:mainfrom
he-yufeng wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
On Chinese Windows systems the default subprocess encoding is GBK,
which crashes on UTF-8 filenames from git ls-files. Pass explicit
encoding="utf-8" and errors="replace" to all three subprocess.run
calls in file_filter.py.
Also guard _parse_ls_files_output against None stdout so the
AttributeError ('NoneType' has no attribute 'split') doesn't
propagate when the subprocess fails silently.
Fixes MoonshotAI#1866
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Chinese Windows systems,
subprocess.run(..., text=True)uses the system default encoding (GBK), which crashes whengit ls-filesoutputs UTF-8 filenames containing Chinese characters.This PR:
encoding="utf-8"anderrors="replace"to all threesubprocess.runcalls infile_filter.py_parse_ls_files_outputagainstNonestdout to prevent theAttributeError: 'NoneType' object has no attribute 'split'cascadeFixes #1866
Changes
1 file changed, 10 insertions, 2 deletions — all in
src/kimi_cli/utils/file_filter.pyTest plan
subprocess.runcalls now specifyencoding="utf-8"@file completion should work withoutUnicodeDecodeError